import Vue from 'vue'
import VueRouter from 'vue-router'
import store from './store'
import contentsEnum from './config/contents.js'
import ColumnEdit from './docs/columnEdit.md'
import sortTable from './docs/sortTable.md'
import chart from './docs/chart.md'
import card from './docs/card.md'

const routes = [
  {
    path: '/',
    component: ColumnEdit,
    name: 'default'
  },
  {
    path: '/columnEdit',
    name: 'columnEdit',
    component: ColumnEdit
  }, 
  {
    path: '/sortTable',
    name: 'sortTable',
    component: sortTable
  },
  {
    path: '/card',
    name: 'card',
    component: card
  },
  {
    path: '/chart',
    name: 'chart',
    component: chart
  }
]

Vue.use(VueRouter)

const router = new VueRouter({
  // mode: 'history',
  // base: '/root/ry/html',
  routes
})

router.beforeEach((to, from, next) => {
  let path = to.path
  if(path === '/') path = '/columnEdit'
  store.state.contents = contentsEnum[path] || []
  next()
})

export default router
